function plot_FOX_eta_m_bs_v1(Fox_model,subsample,inc,set_seed)

% Collect_Fox_discrete_FEdemoshrt_grID_wtp_tomlab_varagin_j_bs(subsample,inc,set_seed,matlab_seed,get_nb_draws)
% do \\c3\rdat\SHoude\Research\EEgap\EEgap_scripts\plot_Fox_contour_3dim_bs.do 

path_to_results_folder='\\c3\rdat\SHoude\Research\EEgap\EEgap_results\';
 
param_results_fox = strcat('plot_jointpdf_Fox_',Fox_model,'_mixedFEdemoshrt_WTP_v',num2str(subsample),'_inc',num2str(inc),'_sd',num2str(set_seed),'_cty_tau1_grid_v3_all_bs.csv');
param_est     	  = csvread([ path_to_results_folder param_results_fox]);
	
p10 = [1:10]/10;
pdf10_edge = quantile(param_est(:,3),p10);
pdf3_edge =[0 5 15 max(param_est(:,3))];
[pdf3_color_id] = discretize(param_est(:,3),pdf3_edge);

tstats2_edge = [0 1.1 max(param_est(:,7))];
tstats2_color_id = discretize(param_est(:,7),tstats2_edge);
param_est_g=[param_est, pdf3_color_id, tstats2_color_id];

group_pdf=findgroups(pdf3_color_id,tstats2_color_id);
nb_group=max(group_pdf);
param_est_g=[param_est_g, group_pdf];
for j=1:nb_group
	group_id(:,j)= group_pdf==j;
end
%pdf/tstats/group
% 1 1 1
% 1 2 2
% 2 1 3
% 2 2 4
% 3 1 5
% 3 2 6
 fig1=figure(1)
hold on
% pdf < 5, tstats < 1.1
h1=scatter3(param_est(group_id(:,1),1),param_est(group_id(:,1),2),param_est(group_id(:,1),3),50,'o');
h1.MarkerFaceColor = [1 1 1];
h1.MarkerEdgeColor = [0 0 0.5];

% pdf < 5, tstats >= 1.1
h2=scatter3(param_est(group_id(:,2),1),param_est(group_id(:,2),2),param_est(group_id(:,2),3),50,'*');
h2.MarkerFaceColor = [1 1 1];
h2.MarkerEdgeColor = [0 0 0.5];

% pdf [5,15], tstats < 1.1
h3=scatter3(param_est(group_id(:,3),1),param_est(group_id(:,3),2),param_est(group_id(:,3),3),100,'o');
h3.MarkerFaceColor = [1 1 1];
h3.MarkerEdgeColor = [0 0.75 0];

% pdf [5,15], tstats > 1.1
h4=scatter3(param_est(group_id(:,4),1),param_est(group_id(:,4),2),param_est(group_id(:,4),3),100,'*');
h4.MarkerFaceColor = [1 1 1];
h4.MarkerEdgeColor = [0 0.75 0];

% pdf > 15, tstats < 1.1
h5=scatter3(param_est(group_id(:,5),1),param_est(group_id(:,5),2),param_est(group_id(:,5),3),150,'o');
h5.MarkerFaceColor = [1 1 1];
h5.MarkerEdgeColor = [1 0 0];

if inc ~= 1
% pdf > 15, tstats >= 1.1
h6=scatter3(param_est(group_id(:,6),1),param_est(group_id(:,6),2),param_est(group_id(:,6),3),150,'*');
h6.MarkerFaceColor = [1 1 1];
h6.MarkerEdgeColor = [1 0 0];
end

xlabel('Coefficient on Price: \eta','Fontsize',16)
 ylabel('Misperception: m','Fontsize',16)
 zlabel('Estimated PDF Weight','Fontsize',16)
ylim( [-3,6] );
xlim( [-35,5] );
%xt = get(gca, 'XTick');
%set(xt, 'fontsize', 16)
set(gca,'fontsize',12) 
%a = get(gca,'XTickLabel');
%set(gca,'XTickLabel',a,'FontName','Times','fontsize',18)
 
%Extract mean from FKRB estimator

if subsample==11000
	if inc==16
	 line([-5.431913,-5.431913],[-3,6],[0,0],'Color','k' );
	 line([-35,5],[0.7650573,0.7650573],[0,0] ,'Color','k' );
	elseif inc==1
	 line([-6.421407,-6.421407],[-3,6],[0,0],'Color','k' );
	 line([-35,5],[0.3539926,0.3539926],[0,0] ,'Color','k' );
	elseif inc==2
	 line([-6.261386,-6.261386],[-3,6],[0,0],'Color','k' );
	 line([-35,5],[0.4845289,0.4845289],[0,0] ,'Color','k' );
	elseif inc==3
	 line([-5.604053,-5.604053],[-3,6],[0,0],'Color','k' );
	 line([-35,5],[0.7280716,0.7280716],[0,0] ,'Color','k' );
	elseif inc==4
	 line([-5.082855,-5.082855],[-3,6],[0,0],'Color','k' );
	 line([-35,5],[0.8185474,0.8185474],[0,0] ,'Color','k' );
	elseif inc==5
	 line([-5.111113,-5.111113],[-3,6],[0,0],'Color','k' );
	 line([-35,5],[0.9405871,0.9405871],[0,0] ,'Color','k' );
	elseif inc==6
	 line([-4.592757,-4.592757],[-3,6],[0,0],'Color','k' );
	 line([-35,5],[1.000794,1.000794],[0,0] ,'Color','k' );
	end
elseif subsample==44000
	if inc==16
     if strcmp(Fox_model,'discrete')    
	  line([-5.431913,-5.431913],[-3,6],[0,0],'Color','k' );
	  line([-35,5],[0.7650573,0.7650573],[0,0] ,'Color','k' );
     elseif strcmp(Fox_model,'discretev5') 
      line([-5.357534,-5.357534],[-3,6],[0,0],'Color','k' );
	  line([-35,5],[0.7911761,0.7911761],[0,0] ,'Color','k' );
	 elseif strcmp(Fox_model,'discretev6') 
      line([-5.435024,-5.435024],[-3,6],[0,0],'Color','k' );
	  line([-35,5],[0.7624894,0.7624894],[0,0] ,'Color','k' ); 
     elseif strcmp(Fox_model,'discretev7')    
      line([-5.237717,-5.237717],[-3,6],[0,0],'Color','k' );
	  line([-35,5],[0.7336762,0.7336762],[0,0] ,'Color','k' );
     elseif strcmp(Fox_model,'discrete_3tau')
      line([-5.58872,-5.58872],[-3,6],[0,0],'Color','k' );
	  line([-35,5],[0.7778516,0.7778516],[0,0] ,'Color','k' ); 
     end
    elseif inc==1
	 line([-6.421407,-6.421407],[-3,6],[0,0],'Color','k' );
	 line([-35,5],[0.3539926,0.3539926],[0,0] ,'Color','k' );
	elseif inc==2
	 line([-6.261386,-6.261386],[-3,6],[0,0],'Color','k' );
	 line([-35,5],[0.4845289,0.4845289],[0,0] ,'Color','k' );
	elseif inc==3
	 line([-5.604053,-5.604053],[-3,6],[0,0],'Color','k' );
	 line([-35,5],[0.7280716,0.7280716],[0,0] ,'Color','k' );
	elseif inc==4
	 line([-5.082855,-5.082855],[-3,6],[0,0],'Color','k' );
	 line([-35,5],[0.8185474,0.8185474],[0,0] ,'Color','k' );
	elseif inc==5
	 line([-5.111113,-5.111113],[-3,6],[0,0],'Color','k' );
	 line([-35,5],[0.9405871,0.9405871],[0,0] ,'Color','k' );
	elseif inc==6
	 line([-4.592757,-4.592757],[-3,6],[0,0],'Color','k' );
	 line([-35,5],[1.000794,1.000794],[0,0] ,'Color','k' );
	end
end


if inc==16
  if strcmp(Fox_model,'discrete')   
         Lobj=legend('pdf: [0,5), t-stat: [0,1.1)',...
                'pdf: [0,5), t-stat: [1.1,\infty)',...
                 'pdf: [5,15), t-stat: [0,1.1)',...
                  'pdf: [5,15), t-stat: [1.1,\infty)',...
                   'pdf: [15,100], t-stat: [0,1.1)',...
                    'pdf: [15,100], t-stat: [1.1,\infty)',...
                    'mean \eta: -5.43',...
                    'mean m: 0.77',...
                    'Location','NorthWest');
        EG = findobj(Lobj,'type','text');
        LEG.FontSize = 10;
  elseif strcmp(Fox_model,'discretev5')
        Lobj=legend('pdf: [0,5), t-stat: [0,1.1)',...
                'pdf: [0,5), t-stat: [1.1,\infty)',...
                 'pdf: [5,15), t-stat: [0,1.1)',...
                  'pdf: [5,15), t-stat: [1.1,\infty)',...
                   'pdf: [15,100], t-stat: [0,1.1)',...
                    'pdf: [15,100], t-stat: [1.1,\infty)',...
                    'mean \eta: -5.34',...
                    'mean m: 0.79',...
                    'Location','NorthWest');
        EG = findobj(Lobj,'type','text');
        LEG.FontSize = 10;
        
        %-5.357534	0.7911761	0.153497	0.0747381

    elseif strcmp(Fox_model,'discretev6')
        Lobj=legend('pdf: [0,5), t-stat: [0,1.1)',...
                'pdf: [0,5), t-stat: [1.1,\infty)',...
                 'pdf: [5,15), t-stat: [0,1.1)',...
                  'pdf: [5,15), t-stat: [1.1,\infty)',...
                   'pdf: [15,100], t-stat: [0,1.1)',...
                    'pdf: [15,100], t-stat: [1.1,\infty)',...
                    'mean \eta: -5.44',...
                    'mean m: 0.76',...
                    'Location','NorthWest');
        EG = findobj(Lobj,'type','text');
        LEG.FontSize = 10;      
        
  elseif strcmp(Fox_model,'discretev7')
        Lobj=legend('pdf: [0,5), t-stat: [0,1.1)',...
                'pdf: [0,5), t-stat: [1.1,\infty)',...
                 'pdf: [5,15), t-stat: [0,1.1)',...
                  'pdf: [5,15), t-stat: [1.1,\infty)',...
                   'pdf: [15,100], t-stat: [0,1.1)',...
                    'pdf: [15,100], t-stat: [1.1,\infty)',...
                    'mean \eta: -5.24',...
                    'mean m: 0.73',...
                    'Location','NorthWest');
        EG = findobj(Lobj,'type','text');
        LEG.FontSize = 10;
      
     %-5.237717	0.7336762	0.1490462	0.0670671
   
      
  elseif strcmp(Fox_model,'discrete_3tau')
  Lobj=legend('pdf: [0,5), t-stat: [0,1.1)',...
                'pdf: [0,5), t-stat: [1.1,\infty)',...
                 'pdf: [5,15), t-stat: [0,1.1)',...
                  'pdf: [5,15), t-stat: [1.1,\infty)',...
                   'pdf: [15,100], t-stat: [0,1.1)',...
                    'pdf: [15,100], t-stat: [1.1,\infty)',...
                    'mean \eta: -5.59',...
                    'mean m: 0.78',...
                    'Location','NorthWest');
        EG = findobj(Lobj,'type','text');
        LEG.FontSize = 10;
        
    %-5.58872	0.7778516	0.1796701	0.0983592
      
  end

elseif inc==1
    Lobj=legend('pdf: [0,5), t-stat: [0,1.1)',...
        'pdf: [0,5), t-stat: [1.1,\infty)',...
         'pdf: [5,15), t-stat: [0,1.1)',...
          'pdf: [5,15), t-stat: [1.1,\infty)',...
           'pdf: [15,100], t-stat: [0,1.1)',...
            'pdf: [15,100], t-stat: [1.1,\infty)',...
            'mean \eta: -6.42',...
            'mean m: 0.35',...
            'Location','NorthWest');
EG = findobj(Lobj,'type','text');
LEG.FontSize = 10;
elseif inc==2
 
 Lobj=legend('pdf: [0,5), t-stat: [0,1.1)',...
        'pdf: [0,5), t-stat: [1.1,\infty)',...
         'pdf: [5,15), t-stat: [0,1.1)',...
          'pdf: [5,15), t-stat: [1.1,\infty)',...
           'pdf: [15,100], t-stat: [0,1.1)',...
            'pdf: [15,100], t-stat: [1.1,\infty)',...
            'mean \eta: -6.26',...
            'mean m: 0.48',...
            'Location','NorthWest');
EG = findobj(Lobj,'type','text');
LEG.FontSize = 10;
 
elseif inc==3
 
 Lobj=legend('pdf: [0,5), t-stat: [0,1.1)',...
        'pdf: [0,5), t-stat: [1.1,\infty)',...
         'pdf: [5,15), t-stat: [0,1.1)',...
          'pdf: [5,15), t-stat: [1.1,\infty)',...
           'pdf: [15,100], t-stat: [0,1.1)',...
            'pdf: [15,100], t-stat: [1.1,\infty)',...
            'mean \eta: -5.60',...
            'mean m: 0.73',...
            'Location','NorthWest');
EG = findobj(Lobj,'type','text');
LEG.FontSize = 10;
 
elseif inc==4
 
 Lobj=legend('pdf: [0,5), t-stat: [0,1.1)',...
        'pdf: [0,5), t-stat: [1.1,\infty)',...
         'pdf: [5,15), t-stat: [0,1.1)',...
          'pdf: [5,15), t-stat: [1.1,\infty)',...
           'pdf: [15,100], t-stat: [0,1.1)',...
            'pdf: [15,100], t-stat: [1.1,\infty)',...
            'mean \eta: -5.08',...
            'mean m: 0.82',...
            'Location','NorthWest');
EG = findobj(Lobj,'type','text');
LEG.FontSize = 10;

elseif inc==5
 
 Lobj=legend('pdf: [0,5), t-stat: [0,1.1)',...
        'pdf: [0,5), t-stat: [1.1,\infty)',...
         'pdf: [5,15), t-stat: [0,1.1)',...
          'pdf: [5,15), t-stat: [1.1,\infty)',...
           'pdf: [15,100], t-stat: [0,1.1)',...
            'pdf: [15,100], t-stat: [1.1,\infty)',...
            'mean \eta: -5.11',...
            'mean m: 0.94',...
            'Location','NorthWest');
EG = findobj(Lobj,'type','text');
LEG.FontSize = 10;

elseif inc==6
 
 Lobj=legend('pdf: [0,5), t-stat: [0,1.1)',...
        'pdf: [0,5), t-stat: [1.1,\infty)',...
         'pdf: [5,15), t-stat: [0,1.1)',...
          'pdf: [5,15), t-stat: [1.1,\infty)',...
           'pdf: [15,100], t-stat: [0,1.1)',...
            'pdf: [15,100], t-stat: [1.1,\infty)',...
            'mean \eta: -4.59',...
            'mean m: 1.00',...
            'Location','NorthWest');
EG = findobj(Lobj,'type','text');
LEG.FontSize = 10;

end

            
grid on 

plot_eta_results = strcat(path_to_results_folder,'plot_joint_eta_m_FKRB_mixed_',Fox_model,num2str(subsample),'_inc_',num2str(inc),'_seed_',num2str(set_seed),'.png');
saveas(fig1,plot_eta_results) 
hold off

view(3)
plot_eta_results2 = strcat(path_to_results_folder,'plot_joint_eta_m_FKRB_mixed_',Fox_model,num2str(subsample),'_inc_',num2str(inc),'_seed_',num2str(set_seed),'_view3.png');
saveas(fig1,plot_eta_results2) 


clear fig1 

%%
% eta
param_results_etafox = strcat('plot_marginaleta_Fox_',Fox_model,'_mixedFEdemoshrt_WTP_v',num2str(subsample),'_inc',num2str(inc),'_sd',num2str(set_seed),'_cty_tau1_grid_v3_all_bs.csv');
param_eta     	  = csvread([ path_to_results_folder param_results_etafox]);
	

tstats2_edge = [0 1.1 max(param_eta(:,6))];
tstats2_color_id = discretize(param_eta(:,6),tstats2_edge);
param_eta_g=[param_eta, tstats2_color_id];

for j=1:2
	group_eta_id(:,j)= tstats2_color_id==j;
end

fig2=figure(2)
hold on
% pdf < 5, tstats < 1.1
h1=scatter(param_eta(group_eta_id(:,1),1),param_eta(group_eta_id(:,1),2),50,'o');
h1.MarkerFaceColor = [1 1 1];
h1.MarkerEdgeColor = [0 0 0.5];

% pdf < 5, tstats >= 1.1
h2=scatter(param_eta(group_eta_id(:,2),1),param_eta(group_eta_id(:,2),2),50,'*');
h2.MarkerFaceColor = [1 1 1];
h2.MarkerEdgeColor = [0 0 0.5];


xlabel('Coefficient on Price: \eta','Fontsize',16)
ylabel('Estimated PDF Weight','Fontsize',16)
ylim( [0,80] );
xlim( [-35,5] );
%xt = get(gca, 'XTick');
%set(xt, 'fontsize', 16)
set(gca,'fontsize',12) 
%a = get(gca,'XTickLabel');
%set(gca,'XTickLabel',a,'FontName','Times','fontsize',18)
 
%line([-5.431913,-5.431913],[0,80],'Color','k' );

if inc==16
 if strcmp(Fox_model,'discrete')   
 line([-5.431913,-5.431913],[0,80],'Color','k' );
 %line([-35,5],[0.7650573,0.7650573],[0,0] ,'Color','k' );
     elseif strcmp(Fox_model,'discretev5')
     line([-5.357534,-5.357534],[0,80],'Color','k' );

     elseif strcmp(Fox_model,'discretev5')
     line([-5.435024,-5.435024],[0,80],'Color','k' );
     
     elseif strcmp(Fox_model,'discretev7')
     line([-5.237717,-5.237717],[0,80],'Color','k' );

     elseif strcmp(Fox_model,'discrete_3tau')    
     line([-5.58872,-5.58872],[0,80],'Color','k' );

     end
 
elseif inc==1
 line([-6.421407,-6.421407],[0,80],'Color','k' );
 %line([-35,5],[0.3539926,0.3539926],[0,0] ,'Color','k' );
elseif inc==2
 line([-6.261386,-6.261386],[0,80],'Color','k' );
 %line([-35,5],[0.4845289,0.4845289],[0,0] ,'Color','k' );
elseif inc==3
 line([-5.604053,-5.604053],[0,80],'Color','k' );
 %line([-35,5],[0.7280716,0.7280716],[0,0] ,'Color','k' );
elseif inc==4
 line([-5.082855,-5.082855],[0,80],'Color','k' );
 %line([-35,5],[0.8185474,0.8185474],[0,0] ,'Color','k' );
elseif inc==5
 line([-5.111113,-5.111113],[0,80],'Color','k' );
 %line([-35,5],[0.9405871,0.9405871],[0,0] ,'Color','k' );
elseif inc==6
 line([-4.592757,-4.592757],[0,80],'Color','k' );
 %line([-35,5],[1.000794,1.000794],[0,0] ,'Color','k' );
end



if inc==16
 if strcmp(Fox_model,'discrete')
 Lobj=legend('t-stat: [0,1.1)',...
            't-stat: [1.1,\infty)',...
            'mean \eta: -5.43',...
            'Location','NorthWest');
EG = findobj(Lobj,'type','text');
LEG.FontSize = 10;

 elseif strcmp(Fox_model,'discretev5') 
  Lobj=legend('t-stat: [0,1.1)',...
            't-stat: [1.1,\infty)',...
            'mean \eta: -5.36',...
            'Location','NorthWest');
EG = findobj(Lobj,'type','text');
LEG.FontSize = 10;
 
  elseif strcmp(Fox_model,'discretev6') 
  Lobj=legend('t-stat: [0,1.1)',...
            't-stat: [1.1,\infty)',...
            'mean \eta: -5.44',...
            'Location','NorthWest');
EG = findobj(Lobj,'type','text');
LEG.FontSize = 10;

 elseif strcmp(Fox_model,'discretev7')
  Lobj=legend('t-stat: [0,1.1)',...
            't-stat: [1.1,\infty)',...
            'mean \eta: -5.24',...
            'Location','NorthWest');
EG = findobj(Lobj,'type','text');
LEG.FontSize = 10;
 
 elseif strcmp(Fox_model,'discrete_3tau')     
   Lobj=legend('t-stat: [0,1.1)',...
            't-stat: [1.1,\infty)',...
            'mean \eta: -5.59',...
            'Location','NorthWest');
EG = findobj(Lobj,'type','text');
LEG.FontSize = 10;
 
 end

elseif inc==1
 Lobj=legend('t-stat: [0,1.1)',...
            't-stat: [1.1,\infty)',...
            'mean \eta: -6.42',...
            'Location','NorthWest');
EG = findobj(Lobj,'type','text');
LEG.FontSize = 10;
elseif inc==2
 Lobj=legend('t-stat: [0,1.1)',...
            't-stat: [1.1,\infty)',...
            'mean \eta: -6.55',...
            'Location','NorthWest');
EG = findobj(Lobj,'type','text');
LEG.FontSize = 10;
elseif inc==3
 Lobj=legend('t-stat: [0,1.1)',...
            't-stat: [1.1,\infty)',...
            'mean \eta: -5.60',...
            'Location','NorthWest');
EG = findobj(Lobj,'type','text');
LEG.FontSize = 10;
elseif inc==4
 Lobj=legend('t-stat: [0,1.1)',...
            't-stat: [1.1,\infty)',...
            'mean \eta: -5.08',...
            'Location','NorthWest');
EG = findobj(Lobj,'type','text');
LEG.FontSize = 10;
elseif inc==5
 Lobj=legend('t-stat: [0,1.1)',...
            't-stat: [1.1,\infty)',...
            'mean \eta: -5.11',...
            'Location','NorthWest');
EG = findobj(Lobj,'type','text');
LEG.FontSize = 10;
elseif inc==6
Lobj=legend('t-stat: [0,1.1)',...
            't-stat: [1.1,\infty)',...
            'mean \eta: -4.59',...
            'Location','NorthWest');
EG = findobj(Lobj,'type','text');
LEG.FontSize = 10;
end
            
grid on 

plot_eta_results = strcat(path_to_results_folder,'plot_marginal_eta_FKRB_mixed_',Fox_model,num2str(subsample),'_inc_',num2str(inc),'_seed_',num2str(set_seed),'_v1.png');
saveas(fig2,plot_eta_results) 
hold off

clear fig2

fig3=figure(3)
hold on
% pdf < 5, tstats < 1.1
h1=scatter(param_eta(:,1),param_eta(:,2),50,'o');
h1.MarkerFaceColor = [1 1 1];
h1.MarkerEdgeColor = [0 0 0.5];

for j=1:length(param_eta(:,1))
	line([param_eta(j,1),param_eta(j,1)],[param_eta(j,4),param_eta(j,5)],'Color',[0 0 0.5]);
end


xlabel('Coefficient on Price: \eta','Fontsize',16)
ylabel('Estimated PDF Weight','Fontsize',16)
ylim( [0,80] );
xlim( [-35,5] );
%xt = get(gca, 'XTick');
%set(xt, 'fontsize', 16)
set(gca,'fontsize',12) 
%a = get(gca,'XTickLabel');
%set(gca,'XTickLabel',a,'FontName','Times','fontsize',18)
 

legend('off')
            
grid on 

plot_eta_results = strcat(path_to_results_folder,'plot_marginal_eta_FKRB_mixed_',Fox_model,num2str(subsample),'_inc_',num2str(inc),'_seed_',num2str(set_seed),'_v2.png');
saveas(fig3,plot_eta_results) 
hold off

clear fig3


%%
% theta
param_results_thetafox = strcat('plot_marginaltheta_Fox_',Fox_model,'_mixedFEdemoshrt_WTP_v',num2str(subsample),'_inc',num2str(inc),'_sd',num2str(set_seed),'_cty_tau1_grid_v3_all_bs.csv');
param_theta     	  = csvread([ path_to_results_folder param_results_thetafox]);
	

tstats2_edge = [0 1.1 max(param_theta(:,6))];
tstats2_color_id = discretize(param_theta(:,6),tstats2_edge);
param_theta_g=[param_theta, tstats2_color_id];

for j=1:2
	group_theta_id(:,j)= tstats2_color_id==j;
end

fig4=figure(4)
hold on
% pdf < 5, tstats < 1.1
h1=scatter(param_theta(group_theta_id(:,1),1),param_theta(group_theta_id(:,1),2),50,'o');
h1.MarkerFaceColor = [1 1 1];
h1.MarkerEdgeColor = [0 0 0.5];

% pdf < 5, tstats >= 1.1
h2=scatter(param_theta(group_theta_id(:,2),1),param_theta(group_theta_id(:,2),2),50,'*');
h2.MarkerFaceColor = [1 1 1];
h2.MarkerEdgeColor = [0 0 0.5];


xlabel('Misperception: m','Fontsize',16)
ylabel('Estimated PDF Weight','Fontsize',16)
ylim( [0,80] );
xlim( [-3,6] );
%xt = get(gca, 'XTick');
%set(xt, 'fontsize', 16)
set(gca,'fontsize',12) 
%a = get(gca,'XTickLabel');
%set(gca,'XTickLabel',a,'FontName','Times','fontsize',18)
 
%line([0.89,0.89],[0,80],'Color','k' );

if inc==16
  if strcmp(Fox_model,'discrete')  
    %line([-5.431913,-5.431913],[-3,6],[0,0],'Color','k' );
    line([0.7650573,0.7650573],[0,80] ,'Color','k' );
  elseif strcmp(Fox_model,'discretev5') 
     line([0.7911761,0.7911761],[0,80] ,'Color','k' );
  elseif strcmp(Fox_model,'discretev6') 
     line([0.7624894,0.7624894],[0,80] ,'Color','k' );   
  elseif strcmp(Fox_model,'discretev7')
      line([0.7336762,0.7336762],[0,80] ,'Color','k' );
  elseif strcmp(Fox_model,'discrete_3tau')    
      line([0.7778516,0.7778516],[0,80] ,'Color','k' );
  end
 
elseif inc==1
 %line([-6.421407,-6.421407],[-3,6],[0,0],'Color','k' );
 line([0.3539926,0.3539926],[0,80] ,'Color','k' );
elseif inc==2
 %line([-6.261386,-6.261386],[-3,6],[0,0],'Color','k' );
 line([0.4845289,0.4845289],[0,80] ,'Color','k' );
elseif inc==3
 %line([-5.604053,-5.604053],[-3,6],[0,0],'Color','k' );
 line([0.7280716,0.7280716],[0,80] ,'Color','k' );
elseif inc==4
 %line([-5.082855,-5.082855],[-3,6],[0,0],'Color','k' );
 line([0.8185474,0.8185474],[0,80] ,'Color','k' );
elseif inc==5
 %line([-5.111113,-5.111113],[-3,6],[0,0],'Color','k' );
 line([0.9405871,0.9405871],[0,80] ,'Color','k' );
elseif inc==6
 %line([-4.592757,-4.592757],[-3,6],[0,0],'Color','k' );
 line([1.000794,1.000794],[0,80] ,'Color','k' );
end


if inc==16
  if strcmp(Fox_model,'discrete')  
    Lobj=legend('t-stat: [0,1.1)',...
                't-stat: [1.1,\infty)',...
                'mean m: 0.77',...
                'Location','NorthWest');
    EG = findobj(Lobj,'type','text');
    LEG.FontSize = 10;
  elseif strcmp(Fox_model,'discretev5')  
     Lobj=legend('t-stat: [0,1.1)',...
                't-stat: [1.1,\infty)',...
                'mean m: 0.79',...
                'Location','NorthWest');
    EG = findobj(Lobj,'type','text');
    LEG.FontSize = 10;  
  elseif strcmp(Fox_model,'discretev6')  
     Lobj=legend('t-stat: [0,1.1)',...
                't-stat: [1.1,\infty)',...
                'mean m: 0.76',...
                'Location','NorthWest');
    EG = findobj(Lobj,'type','text');
    LEG.FontSize = 10;    
  elseif strcmp(Fox_model,'discretev7')  
    Lobj=legend('t-stat: [0,1.1)',...
                't-stat: [1.1,\infty)',...
                'mean m: 0.73',...
                'Location','NorthWest');
    EG = findobj(Lobj,'type','text');
    LEG.FontSize = 10;
  elseif strcmp(Fox_model,'discretev7')    
    Lobj=legend('t-stat: [0,1.1)',...
                't-stat: [1.1,\infty)',...
                'mean m: 0.78',...
                'Location','NorthWest');
    EG = findobj(Lobj,'type','text');
    LEG.FontSize = 10;
  end    
elseif inc==1
 
Lobj=legend('t-stat: [0,1.1)',...
            't-stat: [1.1,\infty)',...
            'mean m: 0.35',...
            'Location','NorthWest');
EG = findobj(Lobj,'type','text');
LEG.FontSize = 10;
elseif inc==2
 
Lobj=legend('t-stat: [0,1.1)',...
            't-stat: [1.1,\infty)',...
            'mean m: 0.48',...
            'Location','NorthWest');
EG = findobj(Lobj,'type','text');
LEG.FontSize = 10;
elseif inc==3
 
Lobj=legend('t-stat: [0,1.1)',...
            't-stat: [1.1,\infty)',...
            'mean m: 0.73',...
            'Location','NorthWest');
EG = findobj(Lobj,'type','text');
LEG.FontSize = 10;
elseif inc==4
  
Lobj=legend('t-stat: [0,1.1)',...
            't-stat: [1.1,\infty)',...
            'mean m: 0.82',...
            'Location','NorthWest');
EG = findobj(Lobj,'type','text');
LEG.FontSize = 10;
elseif inc==5
 
Lobj=legend('t-stat: [0,1.1)',...
            't-stat: [1.1,\infty)',...
            'mean m: 0.94',...
            'Location','NorthWest');
EG = findobj(Lobj,'type','text');
LEG.FontSize = 10;
elseif inc==6
 
Lobj=legend('t-stat: [0,1.1)',...
            't-stat: [1.1,\infty)',...
            'mean m: 1.00',...
            'Location','NorthWest');
EG = findobj(Lobj,'type','text');
LEG.FontSize = 10;
end


            
grid on 

plot_eta_results = strcat(path_to_results_folder,'plot_marginal_theta_FKRB_mixed_',Fox_model,num2str(subsample),'_inc_',num2str(inc),'_seed_',num2str(set_seed),'_v1.png');
saveas(fig4,plot_eta_results) 
hold off

clear fig2

fig5=figure(5)
hold on
% pdf < 5, tstats < 1.1
h1=scatter(param_theta(:,1),param_theta(:,2),50,'o');
h1.MarkerFaceColor = [1 1 1];
h1.MarkerEdgeColor = [0 0 0.5];

for j=1:length(param_theta(:,1))
	line([param_theta(j,1),param_theta(j,1)],[param_theta(j,4),param_theta(j,5)],'Color',[0 0 0.5]);
end


xlabel('Misperception: m','Fontsize',16)
ylabel('Estimated PDF Weight','Fontsize',16)
ylim( [0,80] );
xlim( [-3,6] );
%xt = get(gca, 'XTick');
%set(xt, 'fontsize', 16)
set(gca,'fontsize',12) 
%a = get(gca,'XTickLabel');
%set(gca,'XTickLabel',a,'FontName','Times','fontsize',18)
 

legend('off')
            
grid on 

plot_eta_results = strcat(path_to_results_folder,'plot_marginal_theta_FKRB_mixed_',Fox_model,num2str(subsample),'_inc_',num2str(inc),'_seed_',num2str(set_seed),'_v2.png');
saveas(fig5,plot_eta_results) 
hold off

clear fig5



end